﻿using DevExpress.XtraReports.UI;
using DXApplicationTangche.report;
using DXApplicationTangche.UC.货号管理.service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.货号管理
{
    public partial class Form未入库成衣 : DevExpress.XtraEditors.XtraForm
    {
        public List<BatchExecuteRecordSummaryDTO> batchExecuteRecordSummaryDTOs = new List<BatchExecuteRecordSummaryDTO>();
        public Form未入库成衣()
        {
            InitializeComponent();
            this.刷新();
        }
        private void 刷新()
        {
            this.batchExecuteRecordSummaryDTOs.Clear();
            this.batchExecuteRecordSummaryDTOs = 货号管理Service.getBatchExecuteRecordSummaryAll();
            this.gridControl未入库一览.DataSource = batchExecuteRecordSummaryDTOs;
            this.gridView未入库一览.RefreshData();
        }

        private void simpleButton刷新_Click(object sender, EventArgs e)
        {
            this.刷新();
        }

        private void simpleButton打印pdf_Click(object sender, EventArgs e)
        {
            List<BatchExecuteRecordSummaryReportDTO> batchExecuteRecordSummaryReportDTOs = new List<BatchExecuteRecordSummaryReportDTO>();
            foreach(BatchExecuteRecordSummaryDTO batchExecuteRecordSummaryDTO in this.batchExecuteRecordSummaryDTOs)
            {
                BatchExecuteRecordSummaryReportDTO batchExecuteRecordSummaryReportDTO = new BatchExecuteRecordSummaryReportDTO(batchExecuteRecordSummaryDTO);
                batchExecuteRecordSummaryReportDTOs.Add(batchExecuteRecordSummaryReportDTO);
            }
            XtraReport未入库成衣总计 report未入库成衣总计 = new XtraReport未入库成衣总计(batchExecuteRecordSummaryReportDTOs);
            ReportPrintTool tool未入库成衣总计 = new ReportPrintTool(report未入库成衣总计);
            tool未入库成衣总计.ShowPreviewDialog();
        }

        private void 导出excelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog fileDialog = new SaveFileDialog();
            fileDialog.Title = "导出未入库成衣一览";
            fileDialog.Filter = "Excel文件(*.xls)|*.xls";
            DialogResult dialogResult = fileDialog.ShowDialog(this);
            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                this.gridControl未入库一览.ExportToXls(fileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("保存成功！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
    }
}
